<template>
  <a-select
    class="multi-select-control"
    v-model:value="val"
    mode="tags"
    :options="getDataTitleOptions"
    placeholder="请选择"
  />
</template>

<script lang="ts">
import { defineComponent, computed } from 'vue';
import { GetDataTitleOptions } from '@/global/util/formDesign';

export default defineComponent({
  name: 'MultiSelectControl',
  props: {
    value: {
      type: Array,
      default: () => [],
    },
    controls: {
      type: Object,
      default: () => ({}),
    },
    controlKey: {
      type: String,
      default: () => '',
    },
    formCards: {
      type: Array as any,
      default: () => [],
    },
  },
  setup(props, context) {
    const val = computed({
      get: () => props.value,
      set: (val) =>
        context.emit('updateValue', val, props.controlKey, props.controls),
    });
    const getDataTitleOptions = computed(() =>
      GetDataTitleOptions(props.formCards),
    );

    return {
      val,
      getDataTitleOptions,
    };
  },
});
</script>

<style lang="less" scoped>
.multi-select-control {
  width: 100%;
  font-size: 12px;
  overflow: hidden;
  :deep .ant-select-selector {
    border-radius: 4px;
  }
}
</style>
